package com.fizzkai.p2p.mgrsite.controller;

import com.fizzkai.p2p.bussness.domain.BidRequest;
import com.fizzkai.p2p.bussness.query.BidRequestQuery;
import com.fizzkai.p2p.bussness.service.IBidRequestService;
import com.fizzkai.p2p.core.util.AjaxResult;
import com.fizzkai.p2p.core.util.Constants;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ExpBidRequestController {


    @Autowired
    private IBidRequestService bidRequestService;

    /**
     * 系统 发布体验标 界面
     * @param model
     * @return
     */
    @RequestMapping("/expBidRequestPublishPage")
    public String expBidRequestPublishPage(Model model){
        // 最小 贷款金额
        model.addAttribute("minBidRequestAmount", Constants.BORROW_AMOUNT_MIN);
        // 最小 投标金额
        model.addAttribute("minBidAmount", Constants.BID_AMOUNT_MIN);
        return "expbidrequest/expbidrequestpublish";
    }

    /**
     * 发布体验标
     * @return
     */
    @RequestMapping("/expBidRequestPublish")
    @ResponseBody
    public Object expBidRequestPublish(BidRequest bidRequest){
        bidRequestService.applyExp(bidRequest);
        return new AjaxResult("发布成功");
    }

    /**
     * 发标前审核
     * @return
     */
    @RequestMapping("/expBidRequest_list")
    public String expBidRequest_list(@ModelAttribute("qo")BidRequestQuery qo, Model model){
        //
        qo.setBidRequestType(Constants.BIDREQUEST_TYPE_EXP);
        PageInfo<BidRequest> pageInfo = bidRequestService.query(qo);
        model.addAttribute("pageInfo", pageInfo);
        return "expbidrequest/expbidrequestlist";
    }


}
